﻿using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using Neptuno.Component;
using Neptuno.Model;
using System;

namespace Neptuno.Service
{
    [ServiceContract]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
    public class TiposRegistrosService
    {
        TiposRegistrosComponenent Component = new TiposRegistrosComponenent();

        [WebInvoke(UriTemplate = "{id}", Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        public bool AgregarTipoRegistro(string id, TiposRegistros TipoRegistro)
        {
            return Component.AgregarTipoRegistro(TipoRegistro);
        }

        [WebInvoke(UriTemplate = "{id}", Method = "DELETE", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        public bool Borrar(string id)
        {
            return Component.Borrar(int.Parse(id));
        }


        [WebGet(UriTemplate = "", ResponseFormat = WebMessageFormat.Json)]
        public List<TiposRegistros> Listar()
        {
            List<TiposRegistros> lista = Component.Listar();
            return lista;
        }

        [WebGet(UriTemplate = "{id}", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        public TiposRegistros GetById(string id)
        {
            return Component.GetById(int.Parse(id));
        }

        [WebInvoke(UriTemplate = "{id}", Method = "PUT", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
        public bool Actualizar(string id, TiposRegistros TipoRegistro)
        {
            TipoRegistro.idTipoRegistro = int.Parse(id);
            return Component.Actualizar(TipoRegistro);
        }
    }
}